<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<h1 id="h">请开始抽奖</h1>
	<button id="star">开始</button>
	<button id="stop">停止</button>

	<script>
    var arr=[0,1,2,3,4];

	var ostar=document.getElementById('star');
	var ostop=document.getElementById('stop');
	var oh=document.getElementById('h');
	//setInterval(function(){},时间ms)
	var timer;
	ostar.onclick=function(){
		timer=setInterval(function(){
			var m=parseInt(Math.random()*arr.length);
			oh.innerHTML=arr[m];

		},100)
	}
    //clearInterval(timer)
    ostop.onclick=function(){
    	clearInterval(timer);
    }
	</script>


</body>
</html>